#import "SamplePlugin.h"


@implementation SamplePlugin
-(void) initPlugin{
	[self addProperty:[NumberProperty sliderPropertyWithDefaultvalue:0.5 minValue:-1 maxValue:1] named:@"width"];
	
	[self addProperty:[NumberProperty sliderPropertyWithDefaultvalue:0.5 minValue:0 maxValue:1] named:@"height"];
	[self addProperty:[BoolProperty boolPropertyWithDefaultvalue:1] named:@"green"];
	//[properties setValue:[PluginProperty stringProperty:@"Hahaha"] forKey:@"test"];

//		[properties setValue:[NSNumber numberWithFloat:0.5] forKey:@"width"];
//	NSLog(@"Properties: %@",properties);
	//usleep(ofRandom(0,2000000));
}

-(void) setup{
//	usleep(ofRandom(0,500000));	
}

-(void) draw:(NSDictionary*)drawingInformation{
	ofSetColor(255, 0, 0,255);
	//usleep(ofRandom(0,5000));	

	if([[properties objectForKey:@"green"] boolValue]){
		ofSetColor(0, 255, 0,255);		
	}

	[[properties objectForKey:@"width"] setFloatValue:sin([[drawingInformation valueForKey:@"outputTime.videoTime"] doubleValue] / 200000000.0)];
//		[[properties objectForKey:@"width"] setFloatValue:sin(outputTime->videoTime / 2000.0)];
	ofRect(0.5, 0, [[properties objectForKey:@"width"] floatValue]*0.5, [[properties objectForKey:@"height"] floatValue]);

	
	ofSetColor(255,255,255);
	glScaled(1.0/640, 1.0/480, 1);
	ofDrawBitmapString("Output "+ofToString([[drawingInformation valueForKey:@"outputViewNumber"] intValue], 0), 10, 40);
//	[[properties objectForKey:@"width"] setFloatValue:[[properties objectForKey:@"width"] floatValue]+60.0/ofGetFrameRate() ];
//	ofRect(0, 0, sin([[properties objectForKey:@"width"] floatValue]/100.0), [[properties objectForKey:@"height"] floatValue]);

	
}

/*-(NSMutableDictionary *) properties{
	return [self dictionaryWithValuesForKeys:[NSArray arrayWithObjects:@"name",nil]];
}*/

@end
